﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using DataAccessClass;

namespace ProducerBO
{
    public class PRODUCERR
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _P_ID = -99;
        private string _P_NAME = "";
        private string _P_SEX = "";
        private string _P_EMAIL = "";
        private long _P_PHONE =-99;
        private string _P_ADD = "";
        private string _P_UNAME = "";
        private string _P_PASS= "";
        private bool _ISDELETED = false;
        private bool _ISACTIVE = true;

        public bool ISDELETED
        {
            get
            {
                return _ISDELETED;
            }
            set
            {
                _ISDELETED = value;
            }
        }
        public bool ISACTIVE
        {
            get
            {
                return _ISACTIVE;
            }
            set
            {
                _ISACTIVE = value;
            }
        }

        public long P_ID
        {
            get
            {
                return _P_ID;
            }
            set
            {
                _P_ID = value;
            }
        }


        public string P_NAME
        {
            get
            {
                return _P_NAME;
            }
            set
            {
                _P_NAME = value;
            }
        }

        public string P_SEX
        {
            get
            {
                return _P_SEX;
            }
            set
            {
                _P_SEX = value;
            }
        }
        public string P_EMAIL
        {
            get
            {
                return _P_EMAIL;
            }
            set
            {
                _P_EMAIL = value;
            }
        }
        public long P_PHONE
        {
            get
            {
                return _P_PHONE;
            }
            set
            {
                _P_PHONE= value;
            }
        }
        public string P_ADD
        {
            get
            {
                return _P_ADD;
            }
            set
            {
                _P_ADD = value;
            }
        }
        public string P_UNAME
        {
            get
            {
                return _P_UNAME;
            }
            set
            {
                _P_UNAME = value;
            }
        }
        public string P_PASS
        {
            get
            {
                return _P_PASS;
            }
            set
            {
                _P_PASS = value;
            }
        }
        public long SaveRecord()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@P_ID", P_ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@P_NAME", P_NAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@P_SEX", P_SEX, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@P_EMAIL", P_EMAIL, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@P_PHONE", P_PHONE, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@P_ADD", P_ADD, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@P_UNAME", P_UNAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam7 = DAC.Parameter("@P_PASS", P_PASS, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam8 = DAC.Parameter("@ISDELETED", ISDELETED, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam9 = DAC.Parameter("@ISACTIVE", ISACTIVE, DbType.Boolean, ParameterDirection.Input);

                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6, dbparam7, dbparam8, dbparam9 };
                return DAC.Save("PRODUCERR_SAVE", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long B_ID, string B_NAME, string B_URL, bool ISDELETED, bool ISACTIVE, string andor)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@P_ID", P_ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@P_NAME", P_NAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@P_SEX", P_SEX, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@P_EMAIL", P_EMAIL, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@P_PHONE", P_PHONE, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@P_ADD", P_ADD, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@P_UNAME", P_UNAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam7 = DAC.Parameter("@P_PASS", P_PASS, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam8 = DAC.Parameter("@ISDELETED", ISDELETED, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam9 = DAC.Parameter("@ISACTIVE", ISACTIVE, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam10 = DAC.Parameter("@paraandor", andor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6, dbparam7, dbparam8, dbparam9,dbparam10 };
         
                DataTable dt = DAC.Select("PRODUCERR_GET", dbparamcall);
                return dt;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }

    }
}
